package com.tianyang.yukuaifu.module.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.base.BaseDialog;
import com.tianyang.yukuaifu.module.dialog.interfaces.OnBtnClickL;
import com.tianyang.yukuaifu.module.roundview.RoundTextView;

/**
 * Description：文字提示的dialog
 * Created by 薛勇军 on 2018/7/9.
 */

public class HintDialog extends BaseDialog<HintDialog> {
    private RoundTextView closeRtv;

    private TextView titleTv, contentTv;
    private String title, content, btnTxt;

    private OnBtnClickL clickL;

    public HintDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        showAnim(new BaseAnimatorSet() {
            @Override
            public void setAnimation(View view) {

            }
        });
        View inflate = View.inflate(getContext(), R.layout.dialog_hint, null);
        titleTv = inflate.findViewById(R.id.titleTv);
        contentTv = inflate.findViewById(R.id.contentTv);
        closeRtv = inflate.findViewById(R.id.closeRtv);
        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        if (!TextUtils.isEmpty(title)) {
            titleTv.setText(title);
        }
        if (!TextUtils.isEmpty(content)) {
            contentTv.setVisibility(View.VISIBLE);
            contentTv.setText(content);
        }
        if (!TextUtils.isEmpty(btnTxt)) {
            closeRtv.setText(btnTxt);
        }
        closeRtv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (clickL != null) {
                    clickL.onBtnClick();
                }
                dismiss();
            }
        });
    }

    public HintDialog title(String title) {
        this.title = title;
        return this;
    }

    public HintDialog content(String content) {
        this.content = content;
        return this;
    }

    public HintDialog showBtn(String btnTxt) {
        this.btnTxt = btnTxt;
        return this;
    }

    public HintDialog listener(OnBtnClickL clickL) {
        this.clickL = clickL;
        return this;
    }
}